package com.xx.pmis.persistence.dao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;

import com.xx.pmis.model.Subject;

public class SubjectDAOImpl extends BaseHibernateDAOImpl<Subject> implements SubjectDAO {

	public Subject getSubjectBySubjectID(String subjectID) {
		Subject subject;
		try {
			subject = (Subject) getSession().get(Subject.class, subjectID);
		} catch (HibernateException ex) {
			throw convertHibernateAccessException(ex);
		}
		return subject;
	}

	@SuppressWarnings("unchecked")
	public List<Subject> getAllSubjectByCondition(String hql) {
		List<Subject> subjects;
		try {
			Query query = getSession().createQuery("from Subject" + hql);
			subjects = query.list();
		} catch (HibernateException ex) {
			throw convertHibernateAccessException(ex);
		}
		return subjects;
	}

}
